package nc2db;
import nc2grd.NC2Grd;
import grib2db.grd2array;
import java.util.List;
import java.util.ArrayList;
public class FileName2year {
	public int file2year(String filename)
    {
		//解析grd文件名，获取年份信息
		String [] fname = filename.split("/");
		String  fname_str = fname[fname.length-1];
		//System.out.println(fname_str);
		String []  Sub_name = fname_str.split("\\.");
		//System.out.println(Sub_name.length); 
		 String year2 = Sub_name[Sub_name.length-3];
		// System.out.println(year2);
		int year =  Integer.parseInt(year2);
		return year;
	}
	public static void main(String[] args) {
		// NC2Grd testT = new NC2Grd("/gpfs/home/css/liuxs/ftp/download/","/gpfs/home/css/liuxs/NC2Grd/nc2grd.ncl");
		// ArrayList<String> t = testT.GetGrd("air", "daily");
	    // for(String s: t){
		    // System.out.println(s);
			// FileName2year Fr = new FileName2year();
		   // Fr.file2year(s);
		// }
		String s = "/gpfs/home/css/liuxs/ftp/download/daily/pressure/air.1948.nc.grd";
		FileName2year Fr = new FileName2year();
		Fr.file2year(s);
		 System.out.println("in the FileName2year.java");
		}
		
}